<extend name="CigoAdminLib@Common/pageContent"/>

<block name="tool-bar-btns">
	<a class="btn btn-warning" href="#" onclick="history.go(-1);">
		<i class="fa fa-reply"></i>
		返回列表
	</a>
	<a class="btn btn-success form_post" formId="form" href="<<{:U('edit')}>>">
		<i class="fa fa-check"></i>
		保 存
	</a>
</block>

<block name="content">
	<form id="form">
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-type="hidden" cigo-edit-value="<<{$data['id']}>>"
			     cigo-edit-name="id"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-select" cigo-edit-label="父级菜单"
			     cigo-edit-value="<<{$data['pid']}>>"
			     cigo-edit-data-select-options='<<{$parent_menu_list}>>' cigo-edit-select-width="200"
			     cigo-edit-placeholder="--顶级菜单--" cigo-edit-fun-item-change="parentMenuChange"
			     cigo-edit-select-allowClear cigo-edit-select-clearDefault></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-type="hidden" cigo-edit-value="<<{$data['pid']}>>"
			     cigo-edit-name="pid"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-type="hidden" cigo-edit-value="<<{$data['path']}>>"
			     cigo-edit-name="path"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-label="菜单标题" cigo-edit-type="text"
			     cigo-edit-class="form-control" cigo-edit-style="width:260px;" cigo-edit-value="<<{$data['title']}>>"
			     cigo-edit-name="title" cigo-edit-placeholder="请输入标题..."></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-type="text" cigo-edit-class="form-control"
			     cigo-edit-style="width:260px;" cigo-edit-label="URL" cigo-edit-name="url"
			     cigo-edit-placeholder="请输入链接URL..." cigo-edit-value="<<{$data['url']}>>"
			     cigo-edit-helpblock="用于跳转的URL，支持带http://的URL或U函数参数格式"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-select" cigo-edit-label="URL Target"
			     cigo-edit-data-select-options='<<{$target_list}>>'
			     cigo-edit-value="<<{$data['target']}>>"
			     cigo-edit-name="target" cigo-edit-select-width="190"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-label="菜单Icon" cigo-edit-type="text"
			     cigo-edit-class="form-control" cigo-edit-style="width:260px;"
			     cigo-edit-name="icon" cigo-edit-placeholder="请输入Icon类名..."
			     cigo-edit-value="<<{$data['icon']}>>"
			     cigo-edit-helpblock="菜单Icon使用Font Awesome图标，请输入对应图标类名即可，如：图标&nbsp;<i class='fa fa-plus-square-o'></i>&nbsp;则输入fa-plus-square-o。如不显示则不填即可"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-select" cigo-edit-label="消息提示Label样式"
			     cigo-edit-name="label_class" cigo-edit-value="<<{$data['label_class']}>>"
			     cigo-edit-data-select-options='<<{$label_class_list}>>' cigo-edit-select-width="150"
			     cigo-edit-fun-createitem="selectItemLabelClass" cigo-edit-helpblock="提示Label使用Bootstrap标签样式"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-label="排序" cigo-edit-type="text"
			     cigo-edit-class="form-control" cigo-edit-style="width:260px;"
			     cigo-edit-name="sort" cigo-edit-value="<<{$data['sort']}>>"
			     cigo-edit-placeholder="请输入排序数字..."
			     cigo-edit-helpblock="排序将根据数值大小倒序, 默认为50"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-label="分组" cigo-edit-type="text"
			     cigo-edit-class="form-control" cigo-edit-style="width:260px;"
			     cigo-edit-name="group" cigo-edit-value="<<{$data['group']}>>"
			     cigo-edit-placeholder="请输入菜单分组..."></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-input" cigo-edit-label="分组排序" cigo-edit-type="text"
			     cigo-edit-class="form-control" cigo-edit-style="width:260px;"
			     cigo-edit-name="group_sort" cigo-edit-value="<<{$data['group_sort']}>>"
			     cigo-edit-placeholder="请输入排序数字..."
			     cigo-edit-helpblock="排序将根据数值大小倒序, 默认为50"></div>
		</div>
		<div class="form-group">
			<div class="cigo-edit item-select" cigo-edit-label="是否显示在顶部菜单"
			     cigo-edit-data-select-options='[{"id":"1","text":"显 示"},{"id":"0","text":"隐 藏"}]'
			     cigo-edit-value="<<{$data['show_top_menu']}>>"
			     cigo-edit-name="show_top_menu" cigo-edit-select-width="130"></div>
		</div>
		<div class="form-group btn-group">
			<a id="saveBtn" class="btn btn-success btn-default form_post" href="<<{:U('edit')}>>" formId="form">保 存</a>
			<a class="btn btn-warning btn-default" href="#" onclick="history.go(-1);">返 回</a>
		</div>
	</form>
</block>
<block name="js-footer">
	<script type="text/javascript">
		function selectItemLabelClass(item) {
			var $itemView = $(
				'<span class="label ' + item.id + '">样式</span><span>&nbsp;&nbsp;' + item.text + '</span>'
			);
			return $itemView;
		}

		function parentMenuChange(optionItemData) {
			var parentId = (optionItemData.length > 0) ? optionItemData[0].id : 0;
			var parentPath = (optionItemData.length > 0) ? optionItemData[0].path : '';

			$('input[name="pid"]:first').val(parentId);
			$('input[name="path"]:first').val(parentPath + parentId + ',');
		}

		$("#form").keydown(function (event) {
			if ((event.which || event.keyCode) == 13) {
				$('#saveBtn').trigger('click');
			}
		});
	</script>
</block>
